package org.behrang.macbeans.tab.camino;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import javax.swing.border.Border;
import org.behrang.macbeans.Utils;

/**
 *
 * @author behrangsa
 */
public class CaminoUpperTabControlBorder implements Border, CaminoColors {

    public Insets getBorderInsets(Component c) {
        return new Insets(1, 1, 0, 1);
    }

    public boolean isBorderOpaque() {
        return true;
    }

    public void paintBorder(Component c, Graphics gr, int x, int y, int width, int height) {
        Graphics2D g = (Graphics2D) gr;
        Color oldColor = g.getColor();
        
        int lw = CaminoEditorTabDisplayerUI.MINIMUM_X_POSITION - 1;
        int lh = CaminoEditorTabDisplayerUI.PREFERRED_HEIGHT;
        
        // Utils.prints("X = ", x);
        
        // upper line
        g.setColor(UL);
        g.drawLine(x, y + 1, lw, y + 1);
        // g.drawLine(x, y, lw, y + 1);

        // left line        
        g.drawLine(x, y + 2, x, lh);
        
        // right line
        g.drawLine(x + width - 1, y + 2, x + width - 1, y + lh);

        // background
        g.setColor(BG);
        g.fillRect(x + 1, y + 2, lw, lh - 5);
//
//        // bottom lines
        g.setColor(B1);
        g.drawLine(x + 1, lh - 7, lw, lh - 7);
        g.setColor(B2);
        g.drawLine(x + 1, lh - 6, lw, lh - 6);
        g.setColor(B3);
        g.drawLine(x + 1, lh - 5, lw, lh - 5);
        g.setColor(B4);
        g.drawLine(x + 1, lh - 4, lw, lh - 4);
        g.setColor(B5);
        g.drawLine(x + 1, lh - 3, lw, lh - 3);

        g.setColor(oldColor);
    }
}
